
const Joi = require('joi');
const router = require('koa-router')();
const validationMiddleware = require('../../middleware/validate');
const EmailController = require('../../controllers/system/emailController');

const rulesSchema = {
    '/sendverificationcode': Joi.object({
        email: Joi.string().email().required().messages({
            'string.email': '请输入正确的邮箱格式',
            'string.empty': '邮箱不能为空'
        }),
    }),
    '/verifycode': Joi.object({
        email: Joi.string().email().required().messages({
            'string.email': '请输入正确的邮箱格式',
            'string.empty': '邮箱不能为空'
        }),
        code: Joi.string().required().messages({
            'string.empty': '验证码不能为空'
        }),
    }),
}
router.post('/sendverificationcode', validationMiddleware(rulesSchema), EmailController.sendVerificationCode);
router.post('/verifycode', validationMiddleware(rulesSchema), EmailController.verifyCode);
module.exports = router;